Note: This source code is complete and buildable (with dev-c ++)